package com.cloudptt.api.product.func.call.group.fsm.call;

import com.cloudptt.api.comm.CauseCont;
import com.cloudptt.api.product.func.call.CallConst;
import com.cloudptt.api.product.log.Log;

public class InitialState implements ICallState
{
	private GroupCallAgent agent = null;
	
	public InitialState(GroupCallAgent agent)
	{
		this.agent = agent;
	}

	public int doUserAction(int btnAction)
	{
		if(CallConst.BtnAction_Make == btnAction)
		{
			int result = this.agent.doMakeCallAction();
			if(CauseCont.OperateCheck_Suc == result)
			{
				this.agent.goToState(CallConst.CallState_ConnectingState);
//				gotoConnectingState();
			}
			return result;
		}
		else if(CallConst.BtnAction_Hangup == btnAction)
		{
			return this.agent.doHangupAction();
		}
		return CauseCont.OperateErr_Invalid;
	}

	public void receiveCallAction(int talkAction)
	{
//		if(GroupCallConst.Session_Confirmed_Active_Floor == talkAction
//				|| GroupCallConst.Session_Confirmed_Active_Video == talkAction)
//		{
//			gotoActiviteState();
//			if(GroupCallConst.Session_Confirmed_Active_Floor == talkAction)
//			{
//				this.agent.initFloorAgent();
//			}
//			else if(GroupCallConst.Session_Confirmed_Active_Video == talkAction)
//			{
//				this.agent.initVideoAgent();
//			}
//		}
		//鍥犱负鎸傛柇鏃舵槸鐩存帴鍒板垵濮嬬姸鎬侊紝浣嗘槸杩欎釜鏃跺�欏彲鑳藉懠鍙苟娌℃湁缁撴潫锛岀瓑鏀跺埌杩欎釜娑堟伅锛屽懠鍙墠姝ｅ紡缁撴潫
		if(CallConst.Session_Confirmed_Active == talkAction)
		{
//			gotoActiviteState();
			this.agent.goToState(CallConst.CallState_Activite);
		}
		else if(CallConst.Session_Connecting == talkAction)
		{
//			gotoConnectingState();
			this.agent.goToState(CallConst.CallState_ConnectingState);
		}
		else if(CallConst.Session_Disconnected == talkAction)
		{
//			if(this.agent.getListener() != null)
//			{
//				int callState = getState();
//				this.agent.getListener().updateCallState(agent.getCurCallId(),callState);
//			}
//			this.agent.goToState(CallConst.CallState_DisconnectingState);
		}
	}
	public void receiveSpeakInfo(int type,String speakName)
	{
		
	}
//	public void gotoConnectingState()
//	{
//		ICallState currentState = new ConnectingState(this.agent);
//		this.agent.setCurrentState(currentState);
////		this.talkAgent.doFirst(isPttBtnUp);
//	}
//	public void gotoTalkState()
//	{
//		ITalkState currentState = new TalkState(this.talkAgent);
//		this.talkAgent.setCurrentState(currentState);
//	}
//	public void gotoIdleState()
//	{
//		ICallState currentState = new IdleState(this.talkAgent);
//		this.talkAgent.setCurrentState(currentState);
//	}
//	public void gotoActiviteState()
//	{
//		ICallState currentState = new ActiviteState(this.agent);
//		this.agent.setCurrentState(currentState);
//	}
	public void rollbackState()
	{}

	

	public int getState()
	{
		return CallConst.CallState_InitState;
	}
	public void destory()
	{
	}
}
